import 'package:demo202112/utils/common_appbar.dart';
import 'package:flutter/material.dart';
import 'dart:math' as math;
/// @Author wywinstonwy
/// @Date 2022/1/25 9:19 下午
/// @Description: 

class MyTransformPage extends StatelessWidget {
  const MyTransformPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar('Transform'),
      body: Center(child: _buildRotatedBox(),),
    );
  }

  _buildTransform1(){
    return Container(
      margin: EdgeInsets.only(top: 200,left: 20),
      color: Colors.black,
      child: Transform(
        alignment: Alignment.topRight,
        transform: Matrix4.skewY(0.4),
        child: Container(
          padding: EdgeInsets.all(10),
          color: Colors.deepOrange,
          child: Text('这个效果好看吧？'),
        ),

      ),
    );
  }
  //平移
  _buildOffset(){
    return DecoratedBox(
        decoration: const BoxDecoration(color: Colors.red),
        child: Transform.translate(offset: Offset(-20,-10),
          child: Text('平移效果',style: TextStyle(fontSize: 20,)),
        ),
    );
  }
  //旋转
  _buildRorate(){
    return DecoratedBox(
        decoration: BoxDecoration(color: Colors.red),
        child: Transform.rotate(
          //旋转度数
            angle: math.pi/2,
          child: Text('Hello world'),
        ),
    );
  }
  //放缩
  _buildScale(){
    return DecoratedBox(
        decoration: const BoxDecoration(color: Colors.red),
        child: Transform.scale(scale: 1.5,child: const Text('Hello World'),),
    );
  }

  _buildRow(){
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        DecoratedBox(
            decoration:BoxDecoration(color: Colors.red),
            child: Transform.scale(scale: 1.5,
                child: Text("Hello world")
            )
        ),
        Text("你好", style: TextStyle(color: Colors.green, fontSize: 18.0),)
      ],
    );
  }

  _buildRotatedBox(){
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        DecoratedBox(
          decoration: BoxDecoration(color: Colors.red),
          child: RotatedBox(
            quarterTurns: 1,//旋转90度（1、4）
            child: Text('Hello world')
          ),

        ),
        Text("你好", style: TextStyle(color: Colors.green, fontSize: 18.0),)
      ],
    );
  }

}
